<?php

namespace app\controllers;

use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\web\Response;
use app\models\LoginForm;
use app\models\ContactForm;

use app\services\CampaignLabelService;

class CampaignLabelController extends AuthController {
    public $currentHeader = 'header-campaign';
    public $currentNav = 'label-nav';
    public $pageTitle = '';

    public function init() {
        parent::init();
    }

    public function actionLabelList() {
        $this->pageTitle = $this->t('campaign-label', 'Campaign Label List');
        $this->brandShow = true;
        return $this->show();
    }

    public function actionNewCampaignLabel () {
        $this->pageTitle = $this->t('campaign-label', 'Add New Campaign Label');
        $this->S('campaign_id', null);
        $this->S('solution_id', null);
        return $this->show('newCampaignLabel');
    }

    public function actionCampaignLabelEdit () {
        $this->pageTitle = $this->t('campaign-label', 'Edit Campaign Label');
        $this->label = $this->M('CampaignLabel', $this->I('id'));
        return $this->show();
    }

    public function actionGetCampaignLabels() {
        $labels = $this->service->getAllLabels();
        $this->jsonReturn(['data' => $labels]);
    }

    public function actionNewCampaignLabelHandle() {
        $newLabel = $this->service->saveNewLabel($this->I());
        $this->OK($this->t('campaign-label', 'Create campaign label successfully!'), '', $newLabel);
    }
}//end of CampaignLabelController declaration
